package com.computergames.server.util;

/**
 * 根据userId生成或获取rating值。
 */
public class getOrGenerateRating {

    public static int getOrGenerateRating(int userId)
    {
        RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
        if (redisUtil.hasKey(String.valueOf(userId)))
        {
            return (int) redisUtil.hget(String.valueOf(userId),"rating");
        }
        else
        {
            redisUtil.hset(String.valueOf(userId), "rating", 1000);
            return 1000;
        }
    }
}
